#ifndef HTTPCLIENT_H
#define HTTPCLIENT_H

#include <QObject>
#include "BasePort.h"
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <curl.h>
#include <QTimer>
class HttpClient: public BasePort
{

    Q_OBJECT

public:
    Q_INVOKABLE  HttpClient(QObject *parent = 0);
    ~HttpClient();

    void setPortParam(PortStruct portParam);
    void open();
    void close();
    void write(PortStruct target,QByteArray data);
    void post(PortStruct target,Package package);
     void get(PortStruct target,Package package);
     //static size_t cb_messageAuth_cert(void *data, size_t size, size_t nmemb, void *userp);

private:
     QNetworkAccessManager* naManager;
     QNetworkRequest request;
     CURL *curl;

     QTimer *reconnectTimer;
     int reconnectTimeout;


private slots:
    void replyFinished(QNetworkReply *reply);
    void timeoutSlot();


};



#endif // HTTPCLIENT_H
